package com.yans.views
{
	import com.yans.maps.MapConfig;
	
	import flash.display.BitmapData;
	
	
	public class MapDataVo {
		
		public var id:int;
		public var name:String;
		public var indexXLength:int;
		public var indexYLength:int;
		public var width:int;
		public var height:int;
		public var source:Array;
		public var items:Array;
		public var data:BitmapData;
		
		public function MapDataVo(){
			this.source = [];
			this.items = [];
		}
		public function addItem(_arg1:int, _arg2:int, _arg3:int):ItemDataVo{
			var item:ItemDataVo;
			if ((this.source[_arg2] == null))
			{
				this.source[_arg2] = [];
			};
			if (this.source[_arg2][_arg1] == null)
			{
				item = new ItemDataVo();
				item.indexX = _arg1;
				item.indexY = _arg2;
				item.x = (_arg1 * MapConfig.TILE_SIZE);
				item.y = (_arg2 * MapConfig.TILE_SIZE);
				item.setType(_arg3);
				this.source[_arg2][_arg1] = item;
			} else
			{
				item = this.source[_arg2][_arg1];
				if (item.getType() == _arg3)
				{
					return (null);
				};
				item.setType(_arg3);
			};
			return (item);
		}
		public function addNpcOrMonster(_arg1:Item, _arg2:int, _arg3:int):Object{
			
			var _local4:Object = {
				id:_arg1.id,
					type:_arg1.type,
					indexX:_arg2,
					indexY:_arg3,
					item:_arg1
			};
			this.items.push(_local4);
			return (_local4);
		}
//		public function add(item:Item):Item {
//			items.push(item);
//			return item;
//		}
		public function removeNpcOrMonster(_arg1:Object):void{
			if (this.items.indexOf(_arg1) != -1)
			{
				this.items.splice(this.items.indexOf(_arg1), 1);
			};
		}
		
	}
}